package com._58city.spark.app.dao;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;

/**
 * @author lihao
 * 根据CPC Click日志，转化的Dto对象
 */
public class CPCClickDto implements BaseDto{
	
	public final static int CITY_TYPE_DIRECT = 1; //直营
	public final static int CITY_TYPE_CHANNEL = 2; //渠道
	
	public final static String separator = "|";
	
	public final static char SPLIT = 1;
	public final static int COLUMN_NUM = 53;
    public final static String NULL = "-";
	
    public final static List<String> success_stats = new ArrayList<String>(3);
    static{
    	success_stats.add("1111111");
    	success_stats.add("21");
    	success_stats.add("22");
    }
    
    
	private String cookieId;
	private String userId;
	private String clientIp;
	private String mark;
	private String version;
	private String clickTime;
	private String displayTypeStr;
	
    private String[] displayTypes; //cateids
    
    private String cate2Id;
    private String cate2Name;
	
	private String busiLine; //业务线 
	
	
	private String displayRegion;
	private String placeholder;
	private String pageId;
	private String reference;
	private String httpForwarded;
	private String httpUserAgent;
	private String clickId;
	private String customerId; //点击客户Id
	private String promotionId;
	private String unitId;
	private String entityId;
	private String entityType;
	private String cityId;
	
	private long city1Id;
	private String city1Name;
	private int cityType;
	
	private String entityCategory;
	private String displayId;
	private String displayTime;
	private String adPosition;
	private String displayOrder;
	private String cost;  //实际扣费金额
	private String state1;
	private String state2;
	private String source;
	private String param;
	private String creativeId;
	private String budget;
	private String sumConsume;
	private String bidprice;
	private String abtest;
	private boolean isextend;
	private String platform;
	private String paramid;
	private String qValue;
	private String spm;
	private String utmSource;
	private String spmName;
	private String spmChannel;
	private String spmClicktime;
	private String spmClickid;
	private String pId;
	private String pmcBalance;
	private String couponBalance;
	private String couponPrice;
	private String couponRs;
	private String cash;  //现金
	private String imei;
	private String adact;
	
	protected long formaterTime; //根据时间间隔格式化的时间点。
	
	public CPCClickDto() {
		super();
	}

	public CPCClickDto(String... params) {
		super();
		this.cookieId = params[0];
		this.userId = params[1];
		this.clientIp = params[2];
		this.mark = params[3];
		this.version = params[4];
		this.clickTime = params[5];
		this.displayTypeStr = params[6];
		
		this.displayTypes = StringUtils.split(this.displayTypeStr, '|');
		
		this.displayRegion = params[7];
		this.placeholder = params[8];
		this.pageId = params[9];
		this.reference = params[10];
		this.httpForwarded = params[11];
		this.httpUserAgent = params[12];
		this.clickId = params[13];
		this.customerId = params[14];
		this.promotionId = params[15];
		this.unitId = params[16];
		this.entityId = params[17];
		this.entityType = params[18];
		this.cityId = params[19];
		this.entityCategory = params[20];
		this.displayId = params[21];
		this.displayTime = params[22];
		this.adPosition = params[23];
		this.displayOrder = params[24];
		this.cost = params[25];
		
		if(NULL.equals(this.cost)) this.cost = "0";
		
		this.state1 = params[26];
		this.state2 = params[27];
		this.source = params[28];
		this.param = params[29];
		this.creativeId = params[30];
		this.budget = params[31];
		this.sumConsume = params[32];
		this.bidprice = params[33];
		this.abtest = params[34];
		this.isextend = Boolean.valueOf(params[35]);
		this.platform = params[36];
		this.paramid = params[37];
		this.qValue = params[38];
		this.spm = params[39];
		this.utmSource = params[40];
		this.spmName = params[41];
		this.spmChannel = params[42];
		this.spmClicktime = params[43];
		this.spmClickid = params[44];
		this.pId = params[45];
		this.pmcBalance = params[46];
		this.couponBalance = params[47];
		this.couponPrice = params[48];
		this.couponRs = params[49];
		this.cash = params[50];
		
		if(NULL.equals(this.cash)) this.cash = "0.0";
		
		this.imei = params[51];
		this.adact = params[52];
	}

	
	public String getCookieId() {
		return cookieId;
	}

	public void setCookieId(String cookieId) {
		this.cookieId = cookieId;
	}

	public String getUserId() {
		return userId;
	}

	public void setUserId(String userId) {
		this.userId = userId;
	}

	public String getClientIp() {
		return clientIp;
	}

	public void setClientIp(String clientIp) {
		this.clientIp = clientIp;
	}

	public String getMark() {
		return mark;
	}

	public void setMark(String mark) {
		this.mark = mark;
	}

	public String getVersion() {
		return version;
	}

	public void setVersion(String version) {
		this.version = version;
	}

	public String getClickTime() {
		return clickTime;
	}

	public void setClickTime(String clickTime) {
		this.clickTime = clickTime;
	}



	public String getDisplayTypeStr() {
		return displayTypeStr;
	}


	public void setDisplayTypeStr(String displayTypeStr) {
		this.displayTypeStr = displayTypeStr;
	}


	public String[] getDisplayTypes() {
		return displayTypes;
	}


	public void setDisplayTypes(String[] displayTypes) {
		this.displayTypes = displayTypes;
	}


	public String getBusiLine() {
		return busiLine;
	}


	public void setBusiLine(String busiLine) {
		this.busiLine = busiLine;
	}


	public String getDisplayRegion() {
		return displayRegion;
	}

	public void setDisplayRegion(String displayRegion) {
		this.displayRegion = displayRegion;
	}

	public String getPlaceholder() {
		return placeholder;
	}

	public void setPlaceholder(String placeholder) {
		this.placeholder = placeholder;
	}

	public String getPageId() {
		return pageId;
	}

	public void setPageId(String pageId) {
		this.pageId = pageId;
	}

	public String getReference() {
		return reference;
	}

	public void setReference(String reference) {
		this.reference = reference;
	}

	public String getHttpForwarded() {
		return httpForwarded;
	}

	public void setHttpForwarded(String httpForwarded) {
		this.httpForwarded = httpForwarded;
	}

	public String getHttpUserAgent() {
		return httpUserAgent;
	}

	public void setHttpUserAgent(String httpUserAgent) {
		this.httpUserAgent = httpUserAgent;
	}

	public String getClickId() {
		return clickId;
	}

	public void setClickId(String clickId) {
		this.clickId = clickId;
	}

	public String getCustomerId() {
		return customerId;
	}

	public void setCustomerId(String customerId) {
		this.customerId = customerId;
	}

	public String getPromotionId() {
		return promotionId;
	}

	public void setPromotionId(String promotionId) {
		this.promotionId = promotionId;
	}

	public String getUnitId() {
		return unitId;
	}

	public void setUnitId(String unitId) {
		this.unitId = unitId;
	}

	public String getEntityId() {
		return entityId;
	}

	public void setEntityId(String entityId) {
		this.entityId = entityId;
	}

	public String getEntityType() {
		return entityType;
	}

	public void setEntityType(String entityType) {
		this.entityType = entityType;
	}

	public String getCityId() {
		return cityId;
	}

	public void setCityId(String cityId) {
		this.cityId = cityId;
	}

	public String getEntityCategory() {
		return entityCategory;
	}

	public void setEntityCategory(String entityCategory) {
		this.entityCategory = entityCategory;
	}

	public String getDisplayId() {
		return displayId;
	}

	public void setDisplayId(String displayId) {
		this.displayId = displayId;
	}

	public String getDisplayTime() {
		return displayTime;
	}

	public void setDisplayTime(String displayTime) {
		this.displayTime = displayTime;
	}

	public String getAdPosition() {
		return adPosition;
	}

	public void setAdPosition(String adPosition) {
		this.adPosition = adPosition;
	}

	public String getDisplayOrder() {
		return displayOrder;
	}

	public void setDisplayOrder(String displayOrder) {
		this.displayOrder = displayOrder;
	}

	public String getCost() {
		return cost;
	}

	public void setCost(String cost) {
		this.cost = cost;
	}

	public String getState1() {
		return state1;
	}

	public void setState1(String state1) {
		this.state1 = state1;
	}

	public String getState2() {
		return state2;
	}

	public void setState2(String state2) {
		this.state2 = state2;
	}

	public String getSource() {
		return source;
	}

	public void setSource(String source) {
		this.source = source;
	}

	public String getParam() {
		return param;
	}

	public void setParam(String param) {
		this.param = param;
	}

	public String getCreativeId() {
		return creativeId;
	}

	public void setCreativeId(String creativeId) {
		this.creativeId = creativeId;
	}

	public String getBudget() {
		return budget;
	}

	public void setBudget(String budget) {
		this.budget = budget;
	}

	public String getSumConsume() {
		return sumConsume;
	}

	public void setSumConsume(String sumConsume) {
		this.sumConsume = sumConsume;
	}

	public String getBidprice() {
		return bidprice;
	}

	public void setBidprice(String bidprice) {
		this.bidprice = bidprice;
	}

	public String getAbtest() {
		return abtest;
	}

	public void setAbtest(String abtest) {
		this.abtest = abtest;
	}

	public boolean isIsextend() {
		return isextend;
	}

	public void setIsextend(boolean isextend) {
		this.isextend = isextend;
	}

	public String getPlatform() {
		return platform;
	}

	public void setPlatform(String platform) {
		this.platform = platform;
	}

	public String getParamid() {
		return paramid;
	}

	public void setParamid(String paramid) {
		this.paramid = paramid;
	}

	public String getqValue() {
		return qValue;
	}

	public void setqValue(String qValue) {
		this.qValue = qValue;
	}

	public String getSpm() {
		return spm;
	}

	public void setSpm(String spm) {
		this.spm = spm;
	}

	public String getUtmSource() {
		return utmSource;
	}

	public void setUtmSource(String utmSource) {
		this.utmSource = utmSource;
	}

	public String getSpmName() {
		return spmName;
	}

	public void setSpmName(String spmName) {
		this.spmName = spmName;
	}

	public String getSpmChannel() {
		return spmChannel;
	}

	public void setSpmChannel(String spmChannel) {
		this.spmChannel = spmChannel;
	}

	public String getSpmClicktime() {
		return spmClicktime;
	}

	public void setSpmClicktime(String spmClicktime) {
		this.spmClicktime = spmClicktime;
	}

	public String getSpmClickid() {
		return spmClickid;
	}

	public void setSpmClickid(String spmClickid) {
		this.spmClickid = spmClickid;
	}

	public String getpId() {
		return pId;
	}

	public void setpId(String pId) {
		this.pId = pId;
	}

	public String getPmcBalance() {
		return pmcBalance;
	}

	public void setPmcBalance(String pmcBalance) {
		this.pmcBalance = pmcBalance;
	}

	public String getCouponBalance() {
		return couponBalance;
	}

	public void setCouponBalance(String couponBalance) {
		this.couponBalance = couponBalance;
	}

	public String getCouponPrice() {
		return couponPrice;
	}

	public void setCouponPrice(String couponPrice) {
		this.couponPrice = couponPrice;
	}

	public String getCouponRs() {
		return couponRs;
	}

	public void setCouponRs(String couponRs) {
		this.couponRs = couponRs;
	}

	public String getCash() {
		return cash;
	}

	public void setCash(String cash) {
		this.cash = cash;
	}

	public String getImei() {
		return imei;
	}

	public void setImei(String imei) {
		this.imei = imei;
	}

	public String getAdact() {
		return adact;
	}

	public void setAdact(String adact) {
		this.adact = adact;
	}

 

	public long getFormaterTime() {
		return formaterTime;
	}


	public void setFormaterTime(long formaterTime) {
		this.formaterTime = formaterTime;
	}

	public long getCity1Id() {
		return city1Id;
	}

	public void setCity1Id(long city1Id) {
		this.city1Id = city1Id;
	}

	public String getCity1Name() {
		return city1Name;
	}

	public void setCity1Name(String city1Name) {
		this.city1Name = city1Name;
	}

	public int getCityType() {
		return cityType;
	}

	public void setCityType(int cityType) {
		this.cityType = cityType;
	}

    public String getCate2Id() {
		return cate2Id;
	}

	public void setCate2Id(String cate2Id) {
		this.cate2Id = cate2Id;
	}

	public String getCate2Name() {
		return cate2Name;
	}

	public void setCate2Name(String cate2Name) {
		this.cate2Name = cate2Name;
	}
	
	@Override
	public String toString() {
		return "CPCClickDto ["
				+ (cookieId != null ? "cookieId=" + cookieId + ", " : "")
				+ (userId != null ? "userId=" + userId + ", " : "")
				+ (clientIp != null ? "clientIp=" + clientIp + ", " : "")
				+ (mark != null ? "mark=" + mark + ", " : "")
				+ (version != null ? "version=" + version + ", " : "")
				+ (clickTime != null ? "clickTime=" + clickTime + ", " : "")
				+ (displayTypeStr != null ? "displayTypeStr=" + displayTypeStr
						+ ", " : "")
				+ (displayTypes != null ? "displayTypes="
						+ Arrays.toString(displayTypes) + ", " : "")
				+ (cate2Id != null ? "cate2Id=" + cate2Id + ", " : "")
				+ (cate2Name != null ? "cate2Name=" + cate2Name + ", " : "")
				+ (busiLine != null ? "busiLine=" + busiLine + ", " : "")
				+ (displayRegion != null ? "displayRegion=" + displayRegion
						+ ", " : "")
				+ (placeholder != null ? "placeholder=" + placeholder + ", "
						: "")
				+ (pageId != null ? "pageId=" + pageId + ", " : "")
				+ (reference != null ? "reference=" + reference + ", " : "")
				+ (httpForwarded != null ? "httpForwarded=" + httpForwarded
						+ ", " : "")
				+ (httpUserAgent != null ? "httpUserAgent=" + httpUserAgent
						+ ", " : "")
				+ (clickId != null ? "clickId=" + clickId + ", " : "")
				+ (customerId != null ? "customerId=" + customerId + ", " : "")
				+ (promotionId != null ? "promotionId=" + promotionId + ", "
						: "")
				+ (unitId != null ? "unitId=" + unitId + ", " : "")
				+ (entityId != null ? "entityId=" + entityId + ", " : "")
				+ (entityType != null ? "entityType=" + entityType + ", " : "")
				+ (cityId != null ? "cityId=" + cityId + ", " : "")
				+ "city1Id="
				+ city1Id
				+ ", "
				+ (city1Name != null ? "city1Name=" + city1Name + ", " : "")
				+ "cityType="
				+ cityType
				+ ", "
				+ (entityCategory != null ? "entityCategory=" + entityCategory
						+ ", " : "")
				+ (displayId != null ? "displayId=" + displayId + ", " : "")
				+ (displayTime != null ? "displayTime=" + displayTime + ", "
						: "")
				+ (adPosition != null ? "adPosition=" + adPosition + ", " : "")
				+ (displayOrder != null ? "displayOrder=" + displayOrder + ", "
						: "")
				+ (cost != null ? "cost=" + cost + ", " : "")
				+ (state1 != null ? "state1=" + state1 + ", " : "")
				+ (state2 != null ? "state2=" + state2 + ", " : "")
				+ (source != null ? "source=" + source + ", " : "")
				+ (param != null ? "param=" + param + ", " : "")
				+ (creativeId != null ? "creativeId=" + creativeId + ", " : "")
				+ (budget != null ? "budget=" + budget + ", " : "")
				+ (sumConsume != null ? "sumConsume=" + sumConsume + ", " : "")
				+ (bidprice != null ? "bidprice=" + bidprice + ", " : "")
				+ (abtest != null ? "abtest=" + abtest + ", " : "")
				+ "isextend="
				+ isextend
				+ ", "
				+ (platform != null ? "platform=" + platform + ", " : "")
				+ (paramid != null ? "paramid=" + paramid + ", " : "")
				+ (qValue != null ? "qValue=" + qValue + ", " : "")
				+ (spm != null ? "spm=" + spm + ", " : "")
				+ (utmSource != null ? "utmSource=" + utmSource + ", " : "")
				+ (spmName != null ? "spmName=" + spmName + ", " : "")
				+ (spmChannel != null ? "spmChannel=" + spmChannel + ", " : "")
				+ (spmClicktime != null ? "spmClicktime=" + spmClicktime + ", "
						: "")
				+ (spmClickid != null ? "spmClickid=" + spmClickid + ", " : "")
				+ (pId != null ? "pId=" + pId + ", " : "")
				+ (pmcBalance != null ? "pmcBalance=" + pmcBalance + ", " : "")
				+ (couponBalance != null ? "couponBalance=" + couponBalance
						+ ", " : "")
				+ (couponPrice != null ? "couponPrice=" + couponPrice + ", "
						: "")
				+ (couponRs != null ? "couponRs=" + couponRs + ", " : "")
				+ (cash != null ? "cash=" + cash + ", " : "")
				+ (imei != null ? "imei=" + imei + ", " : "")
				+ (adact != null ? "adact=" + adact + ", " : "")
				+ "formaterTime=" + formaterTime + "]";
	}

	public static void main(String[] args) {
		String s = "8|10";
		String[] sa = StringUtils.split(s, '|');
		Long[] la = new Long[sa.length];
		for(int i=0; i<sa.length; i++){
			la[i] = Long.valueOf(sa[i]);
		}
		
		StringBuffer sb = new StringBuffer();
		for(long one : la){
			sb.append(one).append(separator);
		}
		String res = sb.toString();
		System.out.println(res.substring(0,res.length()-1));
	}

}
